#include "process.h"
#include<string.h>
#include<unistd.h>
#define NUM 100
#define STYLE '#'
void FlushProcess(double total,double current)
{
	char buffer[NUM];
	memset(buffer,0,sizeof(buffer));
	const char* label = "|/-\\";
	int len = strlen(label);
	int num =(int)( current*100 / total);
	int i = 0;
	for(;i <= num;i++)
	{
		buffer[i] = STYLE;
	}
	double rate = current / total;
	printf("[%s][%.2lf%%][%c]\r",buffer,rate*100,label[num%len]);
	fflush(stdout);
}
void process_v1()
{
	char buffer[NUM];
	memset(buffer,0,sizeof(buffer));
	int cnt = 0;
	const char* label = "|/-\\";
	int len = strlen(label);
	while (cnt <= 100)
	{
		double rate = cnt * 100 / NUM;
		printf("[%s][%.2lf%%][%c]\r",buffer,rate,label[cnt%len]);
		fflush(stdout);
		buffer[cnt] = STYLE;
		cnt++;
		usleep(50000);
	}
	printf("\n");
}
